<?php
include("include/db.php");

$in_venue = (int)$_GET['id'];

$result = mysql_query("SELECT * FROM venues WHERE venue_id = '$in_venue'  ", $db);
$myrow = mysql_fetch_array($result, MYSQL_ASSOC);


?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html"/>
    <meta charset="utf-8">

    <title>Sebastopol Documentary Film Festival - <?php echo $myrow['venue_name'];?></title>
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript">
</script>

<link type="text/css" href="main-events.css" rel="stylesheet" />
    
<style type="text/css">
	
	body{color: black;}
	
	a{color: black;}
	.clear{clear: both;}


    .style1 {color: #000000}
    .style3 {
    color: black;
    font-weight: bold;
    font-style: italic;
    }
    
    div.rightbody{
    	background-color: white;
    	color: black;
    
    }

</style>



</head>
<body class="sub">
<div id="container">
<div id="wrapper">
  <div id="left">
    <div class="logo">
      <p><a href="/"><img src="images-events/logo.gif" alt="Sebastopol Documentary Film Festival" width="211" height="239" /></a></p>
    </div>
     	
     	<?php include "include/menu.php"; ?>
    
    <!-- end main nav -->
    <br class="clear" />
  </div>
  <!-- end left -->
  <div id="right">
    <div class="head">
    </div>
    <!-- end banner -->
    <div id="content">

                
                
       <h1><?php echo $myrow['venue_name'];?></h1>
                <?php echo $myrow['venue_address'];?> 
                                <hr>
                <?php echo $myrow['venue_map'];?> 
            				
				<br>
				<hr>
				<h1>Screenings</h1>
				
				 <table width="65%" border="0" class="underline">

              <tbody>
              <?php
              $film_array = array();
	$result = mysql_query("SELECT screenings.event_title, screenings.screen_id, screenings.date, screenings.time, screenings.type, venues.venue_name, venues.venue_id, films.title, films.film_id, films.director, films.year_produced, films.runtime FROM screenings,venues,films WHERE screenings.venue_id = venues.venue_id AND screenings.film_id = films.film_id AND venues.venue_id = '$in_venue' ORDER BY screenings.date, screenings.time", $db);
      	while ($myrow = mysql_fetch_array($result, MYSQL_ASSOC)) { 
      	if($class == 'row2'){$class = 'row1';}else{$class = 'row2';}
      	if($current_day != $myrow['date']){
      	   		$current_day = $myrow['date'];
      	   		?>
      	   		<tr>
      	   			<td colspan="5"><h2><?php echo date("l, F j", strtotime($current_day));?></h2></td>
      	   		</tr>
      	   		<?php
      	   	}
      	
      	
      	if(!in_array($myrow['film_id'], $film_array)){
      	
      		$film_array[$x] = $myrow['film_id'];$x++;
      		if($myrow[type] == 'f'){
      		
      			$title = $myrow[title];
      			$edit_link = "<a href=\"film_edit.php?id=$myrow[film_id]\">$title</a>";
      		
      		
      		}
      		
      		
      		if($myrow[type] == 'e'){
      		
      			$title = $myrow[event_title];
      			$edit_link = "<a href=\"event_edit.php?id=$myrow[screen_id]\">$title</a>";
      		
      		
      		}
      	
      	?>
      	
      	<tr class="<?php echo $class;?>">
      		<td width="10px"></td>
      		<td><?php echo date("g:i a", strtotime(substr($myrow[time], 3)));?></td>
      		<td width="45%"><a href="film.php?screen=<?php echo $myrow[screen_id];?>"><strong><?php echo $title;?></strong></a> <br>
      			<small><?php if($myrow[type] == 'f'){ echo $myrow['director']." ".$myrow['year_produced']." | ".$myrow['runtime']." min."; } ?></small>
      		
      		
      				<?php	
      					$query2 = "SELECT screenings.event_title, screenings.screen_id, screenings.date, screenings.time, screenings.type, venues.venue_name, venues.venue_id, films.title, films.film_id, films.director, films.year_produced, films.runtime, films.ticket_link FROM screenings,venues,films WHERE screenings.venue_id = venues.venue_id AND screenings.film_id = films.film_id AND screenings.date='$current_day' AND screenings.time='$myrow[time]' AND screenings.venue_id='$myrow[venue_id]' AND screenings.film_id != '$myrow[film_id]' ORDER BY screenings.date, screenings.time, screenings.screen_order desc";
						$result2 = mysql_query($query2, $db);
						//echo $query2;
						if(mysql_num_rows($result2) != 0){echo "<div style=\"margin-left:20px; padding-left: 5px; border-left: thin solid grey;\"><em><small>Screens with...</small></em>";}
					      	while ($myrow2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { 
					      	if(!in_array($myrow2['film_id'], $film_array)){
					      	$film_array[$x] = $myrow2['film_id'];$x++;
					      	?>
					      	<br>
					      	<small><strong><a href="screen.php?film=<?php echo $myrow2[screen_id];?>"><?php echo $myrow2[title];?></a></strong> <br>
      			<?php if($myrow2[type] == 'f'){ echo $myrow2['director']." ".$myrow2['year_produced']." | ".$myrow2['runtime']." min."; } ?></small>
					      		
					      <?php } } if(mysql_num_rows($result2) != 0){echo "</div>";} ?>
      		
      		
      		
      		
      		</td>
      		<td><?php if($myrow['ticket_link'] != ''){echo "<a href=\"$myrow[ticket_link]\">$ticket_image</a>";}?></td>
      	</tr>
            		  
   <?php $nolist = ''; } } ?>              

                </tr>
              </tbody>
            </table>
              
                
      <br class="clear" /> 
    </div><!-- end content -->
    <div id="footer">
   <p> &copy;2009 Sebastopol Center for the Arts and Trinity Productions. All rights reserved.</p>
    </div>
  </div><!-- end right -->
  </div><!-- end wrapper -->
  <br class="clear" />
</div><!-- end container -->
</body>
</html>
